#include"logger.h"
#include"public.h"

    Logger::Logger()
    {
        if(!getenv("LOG_LEVEL"))
        {
            m_level=INFO;
        }
        else
        {
            m_level=LogLevelType[getenv("LOG_LEVEL")];//通过环境变量来设置日志级别
        }
        m_LogToTerminal=true;
        m_LogToFile=true;
    }
    void Logger::SetLogToTerminal(bool logToTerminal)
    {
        m_LogToTerminal=logToTerminal;
    }
    bool Logger::GetLogToTerminal()const
    {
        return m_LogToTerminal;
    }

    void Logger::SetLogToLogFile(bool logToFile)
    {
        m_LogToFile=logToFile;
    }
    bool Logger::GetLogToLogFile()const
    {
        return m_LogToFile;
    }

    void Logger::SetLogFile(const std::string&logFileName)
    {
        if(m_logFile.is_open())
        {
            m_logFile.close();
        }
        m_logFile.open(logFileName);
        m_LogToFile=true;
    }

    void Logger::SetLogLevel(LOG_LEVEL level)
    {
        m_level=level;
    }

    LOG_LEVEL Logger::GetLogLevel()const
    {
        return m_level;
    }
    
  /*  
int main()
{
    LOG_INFO<<"hello world 1 ";
 
    //if(INFO>=Logger::GetInstance()->GetLogLevel())
    //*Logger::GetInstance()+=Message(INFO,__FILE__,__FUNCTION__,__LINE__) << "hello world!";
    LOG_ERROR<<"hello world 2 ";
    LOG_DEBUG<<"hello world 3 ";
    LOG_FATAL<<"hello world 4 ";
    return 0;
}
*/